package com.project.utils;

import com.dh.DpsdkCore.fDPSDKAlarmCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.UnsupportedEncodingException;


public class DPSDKAlarmCallback implements fDPSDKAlarmCallback
{

	private static final Logger log = LoggerFactory.getLogger(DPSDKAlarmCallback.class);

	int i =0;
	public void invoke( int nPDLLHandle, byte[] szAlarmId, int nDeviceType, byte[] szCameraId, byte[] szDeviceName, byte[] szChannelName, byte[] szCoding, byte[] szMessage, int nAlarmType, int nEventType, int nLevel, long nTime, byte[] pAlarmData, int nAlarmDataLen, byte[] pPicData, int nPicDataLen)
	{
		i++;
		String strDevName= "";
		String strChnName= "";
		try {
			strDevName = new String(szDeviceName, "UTF-8");
		} catch (UnsupportedEncodingException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		try {
			strChnName = new String(szChannelName,"UTF-8");
		} catch (UnsupportedEncodingException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		log.info("???=%d,nPDLLHandle=%d,szAlarmId=%s,nDeviceType=%d,szCameraId=%s,szDeviceName=%s,szChannelName=%s,szCoding=%s," +
						"szMessage=%s,nAlarmType=%d,nEventType=%d,nLevel=%d,nTime=%d,pAlarmData=%s,nAlarmDataLen=%d",
				i,nPDLLHandle,new String(szAlarmId),nDeviceType,new String(szCameraId),strDevName,strChnName,
				new String(szCoding),new String(szMessage),nAlarmType,nEventType,nLevel,nTime,new String(pAlarmData).trim(),nAlarmDataLen);
		System.out.printf("???=%d,nPDLLHandle=%d,szAlarmId=%s,nDeviceType=%d,szCameraId=%s,szDeviceName=%s,szChannelName=%s,szCoding=%s," +
				"szMessage=%s,nAlarmType=%d,nEventType=%d,nLevel=%d,nTime=%d,pAlarmData=%s,nAlarmDataLen=%d",
				i,nPDLLHandle,new String(szAlarmId),nDeviceType,new String(szCameraId),strDevName,strChnName,
				new String(szCoding),new String(szMessage),nAlarmType,nEventType,nLevel,nTime,new String(pAlarmData).trim(),nAlarmDataLen);
		System.out.println();
		
	}
}
